//
//  XLMineBaseViewController.m
//  Mine
//
//  Created by 于鹏 on 2017/8/26.
//  Copyright © 2017年 YIVIEW. All rights reserved.
//

#import "XLMineBaseViewController.h"
#import "XLMineBaseTableViewCell.h"
#import "XLMineBaseCellModel.h"


@interface XLMineBaseViewController ()<XLTableViewMainControllerDelegate>

@end

@implementation XLMineBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.mainDelegate = self;
   
}

#pragma mark - XLTableViewMainControllerDelegate

- (void)xl_mainTableView:(UITableView *)tableView mainTableViewCell:(XLBaseTableViewCell *)mainCell mainCellModel:(XLBaseCellModel *)mainModel sectionArr:(NSArray *)sectionArr atIndexPath:(NSIndexPath *)indexPath {
    XLMineBaseTableViewCell *cell = (XLMineBaseTableViewCell *)mainCell;
    XLMineBaseCellModel *model = (XLMineBaseCellModel *)mainModel;
    cell.topLine.hidden = indexPath.row != 0;
    //设置最后一个row的分割线距离cell左侧为0
    model.topGrid = indexPath.row == sectionArr.count-1 ? YES:NO;
    cell.indexPath = indexPath;
}

- (void)xl_mainTableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath cellModel:(XLBaseCellModel *)cellModel {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    XLMineBaseCellModel *model = (XLMineBaseCellModel *)cellModel;
    if (model.actionBlock) {
        model.actionBlock(model, indexPath);
    }
}

//- (void)xl_mainTableView:(UITableView *)tableView mainTableViewCell:(XLBaseTableViewCell *)mainCell atIndexPath:(NSIndexPath *)indexPath {
//    XLMineBaseTableViewCell *cell = (XLMineBaseTableViewCell *)mainCell;
//    cell.topLine.hidden = indexPath.row != 0;
//    
//    cell.bottomLine.backgroundColor = [UIColor redColor];
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
